package lab02.test34;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Test34 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("apple");
        list.add("grape");
        list.add("pear");
        list.add("banana");


        System.out.println("集合的最大元素:" + Collections.max(list));      //运用collertions工具类获得最大和最小值
        System.out.println("集合的最小元素:" + Collections.min(list));
        Collections.sort(list);//升序排序
        System.out.println("排序后为:");
        for (String n:list){//遍历
            System.out.println(n);
        }
    }
}

